import { Model } from 'dva';
const global: Model = {
  namespace: 'global',
  state: {
    message: 'hello umi',
    headerShowFlag: true,
  },
  effects: {
    // *todos({ payload }, { put, call, select }) {
    //   const data = yield call(getTods, payload);
    //   console.log(data);
    // },
  },
  subscriptions: {
    // onClick({ dispatch }) {
    //   document.addEventListener('scroll', () => {
    //     dispatch({ type: 'toggleShowFlag' });
    //   });
    // },
  },
  reducers: {
    save(state, action: { type: string; payload: any }) {
      return { ...state, ...action.payload };
    },
    toggleShowFlag(state, action: { type: string; payload: { flag: boolean } }) {
      return { ...state, headerShowFlag: action.payload.flag };
    },
  },
};
export default global;
